﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.Mvc;

namespace ITS.Website.Extentsions
{
    public static class HtmlExtensions
    {
        public static MvcHtmlString ActionLinkMenuItem(this HtmlHelper htmlHelper, String linkText, String actionName, String controllerName)
        {
            //var tag = new TagBuilder("li");
            //if (htmlHelper.ViewContext.RequestContext.IsCurrentRoute(null, controllerName, actionName))
            //{
            //    tag.AddCssClass("current");
            //}
            //tag.InnerHtml = System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName,controllerName).ToString();
            //return MvcHtmlString.Create(tag.ToString());

            if (htmlHelper.ViewContext.RequestContext.IsCurrentRoute(null, controllerName, actionName))
            {
                return System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, null, new { @class = "current" });
            }
            else
            {
                return System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName);
            }
            
        }
        public static MvcHtmlString ActionLinkMenuItem_Parent(this HtmlHelper htmlHelper, String linkText, String actionName, String controllerName)
        {
            if (htmlHelper.ViewContext.RequestContext.IsCurrentRoute(null, controllerName, new[] { actionName, "Details" }))
            {
                return System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, new { id = String.Empty }, new { @class = "current" });
            }
            else return System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, new { id = String.Empty }, null);
        }
        public static MvcHtmlString ActionLinkMenuItem_Sub(this HtmlHelper htmlHelper, String linkText, String actionName, String controllerName, int id)
        {
            //var tag = new TagBuilder("li");
            //tag.InnerHtml = System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, new { id = id }, null).ToString();
            //return MvcHtmlString.Create(tag.ToString());
            return System.Web.Mvc.Html.LinkExtensions.ActionLink(htmlHelper, linkText, actionName, controllerName, new { id = id }, null);
        }
    }
}
